package com.bt.lms.ui.page.first.action;

import com.bt.lms.ui.page.first.PassSet;
import javafx.collections.ObservableList;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.Node;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;

/**
 * 修改密码标签事件
 */
public class PassSetLabMC implements EventHandler {

    /**
     * 界面容器
     */
    private final Pane pane;

    /**
     * 网格
     */
    private final GridPane gridPane;

    /**
     * 构造事件
     * @param pane 需要添加到的容器
     */
    public PassSetLabMC(Pane pane, GridPane gridPane){
        this.pane =pane;
        this.gridPane =gridPane;
    }

    /**
     * 事件实现
     * @param event the event which occurred
     */
    @Override
    public void handle(Event event) {

        ObservableList<Node> gridPaneChildren = gridPane.getChildren();
        int size = gridPaneChildren.size();

        if (size<20){
            PassSet passSet = new PassSet(pane,gridPane);

            ObservableList<Node> children = pane.getChildren();
            children.add(passSet);
        }

    }

}
